package com.ruoyi.web.studentmanagementsystem.controller;

import com.ruoyi.web.studentmanagementsystem.dto.ValidAndValidatedDTO;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.validation.Valid;

/**
 * ClassName: ValidAndValidatedController
 * Package: com.ruoyi.web.studentmanagementsystem.controller
 * Description:
 *
 * @Author Mr. o
 * @Create 2023/11/16 15:14
 * @Version 1.0
 */
@Controller
public class ValidAndValidatedController {
    @RequestMapping("/add")
    @ResponseBody
/*    public String add(@Valid ValidAndValidatedDTO validAndValidatedDTO, BindingResult bindingResult) {
        if(bindingResult.hasErrors()) {
            return bindingResult.getAllErrors().get(0).getDefaultMessage();
        }
        return "新增成功";
    }*/

    public String add(@Validated ValidAndValidatedDTO validAndValidatedDTO) {
        return "新增成功";
    }
}
